<?php

use Biz\tools\GoodsExposureLog;
use Doraemon\tools\ActionLog as tActionLog;

/**
 * @deprecated
 */
class FavListAction extends ActionPlugin
{

    const USER_LEVEL = self::LEVEL_REGISTER;
    const IS_LOG_EXPOSE = 1;

    public function main()
    {
        $province_id = $this->getRequest()->getQuery('province_id', 0);
        $cityId = $this->getRequest()->getQuery('city_id', 0);
        $page = $this->getRequest()->getQuery('page', 1);
        $areaCode = $cityId ? $cityId : $province_id;
        $favList = \Biz\service\GoodsDetail::GoodsFavoriteList($this->uid, $areaCode, $page);
        $favList['list'] = \Biz\tools\helper\Common::getWikiList($favList['list']);
        if(version_compare(\Doraemon\tools\HhzClient::getClientVersion(), \Doraemon\tools\StatSign::WIKI_UP_GRADE_VERSION_522, ">=")){
            if($favList['list']  && is_array($favList['list'])){
                $list = [];
                foreach ($favList['list']  as $val){
                    $list[] = [
                        'type' => \Doraemon\tools\BlockType::TYPE_WIKI,
                        'wiki' => $val,
                        'statSign' => ''
                    ];
                }
                $favList['list'] = $list;
            }
        }
        tActionLog::log($this->uid, [
            'uid' => $this->uid,
            'page' => $page,
        ], tActionLog::BIZ_USER_FAV_WIKI_LIST);
        $this->setSuccess($favList);
        GoodsExposureLog::addLog($this->getRequest(), $favList);
    }
}